package com.example.yunJie.digitalSentry.mapper.one;

import com.example.yunJie.digitalSentry.entity.FaceDownEntity;
import org.apache.ibatis.annotations.*;

import java.io.Serializable;
import java.util.List;


public interface FaceDownMapper {

    @Insert("insert into facedown(devSno,pidList,idCardList,personNameList,templateImgUrlList)\n" +
            "        values(#{devSno},#{pidList},#{idCardList},#{personNameList},#{templateImgUrlList})")
    int insert(FaceDownEntity faceDownEntity);

    @Update("update facedown set pidList = #{pidList},idCardList = #{idCardList},devSno = #{devSno}," +
            "personNameList = #{personNameList}, templateImgUrlList = #{templateImgUrlList} where id = #{id} ")
    int update(FaceDownEntity faceDownEntity);

    @Delete("delete from facedown where id = #{Id}")
    int deleteById(Serializable id);

    @Delete("<script>" +
            "delete from facedown where id in\n" +
            "        <foreach collection=\"list\" item=\"id\" open=\"(\" separator=\",\" close=\")\">\n" +
            "            #{id}\n" +
            "        </foreach>" +
            "</script>")
    int deleteIdList(List<Integer> idList);

    @Select("select * from facedown where id = #{id}")
    FaceDownEntity findId(Serializable id);

    @Select("select * from facedown")
    List<FaceDownEntity> findAll();

    @Select("<script>select * from facedown\n" +
            "        <where>\n" +
            "            <if test=\"personNameList != null and personNameList != ''\"> and personNameList = #{personNameList}</if>\n" +
            "        </where></script>")
    FaceDownEntity findBypersonalName(String personalName);



    @Select("select * from facedown where devSno like concat('%',#{devSno},'%')")
    List<FaceDownEntity> findByDevSno(String devSno);

    @Select("select * from facedown where pidList = #{pidList}")
    FaceDownEntity findBypidList(String pidList);


}
